<?php defined('_XR_EXEC') or die();
/**
 * Cookie class.
 *
 *  
 *
 * @zhoupeng 2012.3.23
 */
class cookie {

	# 设置cookie
	static function set($arg1,$arg2,$expire = 0,$path = '/'){
		if (headers_sent()){
			return FALSE;
		}
		$expire = ($expire == 0) ? 0 : time() + (int) $expire;
		setcookie ($arg1,$arg2,$expire,$path);
	}
	# 得到cookie
	static function get($arg1,$def=NULL){
		return isset($_COOKIE[$arg1])?$_COOKIE[$arg1]:$def;
	}
 

	/**
	 * Nullify and unset a cookie.
	 *
	 * @param   string   cookie name
	 * @param   string   URL path
	 * @param   string   URL domain
	 * @return  boolean
	 */
	public static function delete($name, $path = '/')
	{
		if ( ! isset($_COOKIE[$name]))
			return FALSE;

		// Delete the cookie from globals
		unset($_COOKIE[$name]);

		// Sets the cookie value to an empty string, and the expiration to 24 hours ago
		return cookie::set($name, '', -86400, $path);
	}

} // End cookie